Set up a better build system. Started fixing the build.
This commit is contained in:
parent
9777f08356
commit
f5fa6eb2c7
|
@ -0,0 +1,51 @@
|
||||||
|
# 22 april 2015
|
||||||
|
|
||||||
|
OUTBASE = new
|
||||||
|
OUTDIR = out
|
||||||
|
OBJDIR = .obj
|
||||||
|
|
||||||
|
xHFILES = \
|
||||||
|
ui.h \
|
||||||
|
$(baseHFILES)
|
||||||
|
|
||||||
|
OFILES = \
|
||||||
|
$(baseCFILES:%.c=$(OBJDIR)/%.o) \
|
||||||
|
$(baseMFILES:%.m=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
|
xCFLAGS = \
|
||||||
|
-g \
|
||||||
|
-Wall -Wextra \
|
||||||
|
-Wno-unused-parameter \
|
||||||
|
-Wno-switch \
|
||||||
|
--std=c99 \
|
||||||
|
-fPIC \
|
||||||
|
$(CFLAGS) \
|
||||||
|
$(baseCFLAGS)
|
||||||
|
|
||||||
|
xLDFLAGS = \
|
||||||
|
-g \
|
||||||
|
-fPIC \
|
||||||
|
$(LDFLAGS) \
|
||||||
|
$(baseLDFLAGS)
|
||||||
|
|
||||||
|
OUT = $(OUTDIR)/$(OUTBASE)$(baseSUFFIX)
|
||||||
|
|
||||||
|
$(OUT): $(OFILES) | $(OUTDIR)/.phony
|
||||||
|
$(CC) -o $(OUT) $(OFILES) $(xLDFLAGS)
|
||||||
|
|
||||||
|
.SECONDEXPANSION:
|
||||||
|
$(OBJDIR)/%.o: %.c $(xHFILES) | $$(dir $$@).phony
|
||||||
|
$(CC) -o $@ -c $< $(xCFLAGS)
|
||||||
|
|
||||||
|
# see http://www.cmcrossroads.com/article/making-directories-gnu-make
|
||||||
|
%/.phony:
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
touch $@
|
||||||
|
.PRECIOUS: %/.phony
|
||||||
|
|
||||||
|
ui.h: ui.idl
|
||||||
|
idl2h -extern _UI_EXTERN < ui.idl > ui.h
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(OUTDIR) $(OBJDIR) ui.h
|
||||||
|
.PHONY: clean
|
|
@ -1,9 +1,5 @@
|
||||||
# 22 april 2015
|
# 22 april 2015
|
||||||
|
|
||||||
OUTBASE = new
|
|
||||||
OUTDIR = out
|
|
||||||
OBJDIR = .obj
|
|
||||||
|
|
||||||
# MAME does this so :/
|
# MAME does this so :/
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
OS = windows
|
OS = windows
|
||||||
|
@ -20,64 +16,24 @@ endif
|
||||||
|
|
||||||
include $(OS)/GNUmakeinc.mk
|
include $(OS)/GNUmakeinc.mk
|
||||||
|
|
||||||
HFILES = \
|
baseHFILES = \
|
||||||
ui.h \
|
ui.h \
|
||||||
uipriv.h \
|
uipriv.h \
|
||||||
ui_$(OS).h
|
ui_$(OS).h \
|
||||||
|
$(osHFILES)
|
||||||
|
|
||||||
OFILES = \
|
baseCFILES = \
|
||||||
$(CFILES:%.c=$(OBJDIR)/%.o) \
|
box.c \
|
||||||
$(osCFILES:%.c=$(OBJDIR)/%.o)
|
$(osCFILES)
|
||||||
|
|
||||||
xCFLAGS = \
|
baseMFILES = $(osMFILES)
|
||||||
-g \
|
|
||||||
-Wall -Wextra \
|
|
||||||
-Wno-unused-parameter \
|
|
||||||
-Wno-switch \
|
|
||||||
--std=c99 \
|
|
||||||
-fPIC \
|
|
||||||
$(CFLAGS)
|
|
||||||
|
|
||||||
xLDFLAGS = \
|
baseCFLAGS = $(osCFLAGS)
|
||||||
-g \
|
baseLDFLAGS = -shared $(osLDFLAGS)
|
||||||
-fPIC \
|
baseSUFFIX = $(osLIBSUFFIX)
|
||||||
$(LDFLAGS)
|
|
||||||
|
|
||||||
OUT = $(OUTDIR)/$(OUTBASE)$(osLIBSUFFIX)
|
include GNUbase.mk
|
||||||
|
|
||||||
include test/GNUmakeinc.mk
|
test:
|
||||||
|
$(MAKE) -f GNUmaketest.mk osLIB=$(OUT) osEXESUFFIX=$(osEXESUFFIX)
|
||||||
testOFILES = $(testCFILES:%.c=$(OBJ)/test/%.o)
|
.PHONY: test
|
||||||
|
|
||||||
TEST = $(OUTDIR)/$(OUTBASE)$(osEXESUFFIX)
|
|
||||||
|
|
||||||
default: $(OUT)
|
|
||||||
test: $(TEST)
|
|
||||||
.PHONY: default test
|
|
||||||
|
|
||||||
$(OUT): $(OFILES) dirs
|
|
||||||
$(CC) -o $(OUT) $(OFILES) -shared $(xLDFLAGS) $(osLDFLAGS)
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.c $(HFILES) $(osHFILES) dirs
|
|
||||||
$(CC) -o $@ -c $< $(xCFLAGS) $(osCFLAGS)
|
|
||||||
|
|
||||||
$(TEST): $(OUT) $(testOFILES) dirs $(OBJDIR)/test/.phony
|
|
||||||
$(CC) -o $(TEST) $(testOFILES) $(OUT) $(xLDFLAGS)
|
|
||||||
|
|
||||||
$(OBJDIR)/test/%.o: test/%.c ui.h dirs $(OBJDIR)/test/.phony
|
|
||||||
$(CC) -o $@ -c $< $(xCFLAGS)
|
|
||||||
|
|
||||||
dirs: $(OBJDIR)/.phony $(OBJDIR)/$(OS)/.phony $(OUTDIR)/.phony
|
|
||||||
.PHONY: dirs
|
|
||||||
|
|
||||||
# see http://www.cmcrossroads.com/article/making-directories-gnu-make
|
|
||||||
%/.phony:
|
|
||||||
mkdir -p $(dir $@)
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
ui.h: ui.idl
|
|
||||||
idl2h -extern _UI_EXTERN < ui.idl > ui.h
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf $(OUTDIR) $(OBJDIR) ui.h
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
# 22 april 2015
|
||||||
|
# should never be invoked directly, only ever from the main makefile
|
||||||
|
|
||||||
|
include test/GNUmakeinc.mk
|
||||||
|
|
||||||
|
baseHFILES = \
|
||||||
|
ui.h \
|
||||||
|
$(testHFILES)
|
||||||
|
|
||||||
|
baseCFILES = $(testCFILES)
|
||||||
|
|
||||||
|
baseCFLAGS = $(testCFLAGS)
|
||||||
|
baseLDFLAGS = $(osLIB) $(testLDFLAGS)
|
||||||
|
baseSUFFIX = $(osEXESUFFIX)
|
||||||
|
|
||||||
|
include GNUbase.mk
|
27
new/box.c
27
new/box.c
|
@ -1,4 +1,5 @@
|
||||||
// 7 april 2015
|
// 7 april 2015
|
||||||
|
#include "ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
typedef struct box box;
|
typedef struct box box;
|
||||||
|
@ -229,8 +230,8 @@ static void boxShow(uiControl *c)
|
||||||
if (!b->containerHid) {
|
if (!b->containerHid) {
|
||||||
for (i = 0; i < b->len; i++)
|
for (i = 0; i < b->len; i++)
|
||||||
uiControlContainerShow(b->controls[i].c);
|
uiControlContainerShow(b->controls[i].c);
|
||||||
if (b->parent != NULL)
|
if (b->osContainer != NULL)
|
||||||
uiParentUpdate(b->parent);
|
uiOSContainerUpdate(b->osContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +243,8 @@ static void boxHide(uiControl *c)
|
||||||
b->userHid = 1;
|
b->userHid = 1;
|
||||||
for (i = 0; i < b->len; i++)
|
for (i = 0; i < b->len; i++)
|
||||||
uiControlContainerHide(b->controls[i].c);
|
uiControlContainerHide(b->controls[i].c);
|
||||||
if (b->parent != NULL)
|
if (b->osContainer != NULL)
|
||||||
uiParentUpdate(b->parent);
|
uiOSContainerUpdate(b->osContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void boxContainerShow(uiControl *c)
|
static void boxContainerShow(uiControl *c)
|
||||||
|
@ -255,8 +256,8 @@ static void boxContainerShow(uiControl *c)
|
||||||
if (!b->userHid) {
|
if (!b->userHid) {
|
||||||
for (i = 0; i < b->len; i++)
|
for (i = 0; i < b->len; i++)
|
||||||
uiControlContainerShow(b->controls[i].c);
|
uiControlContainerShow(b->controls[i].c);
|
||||||
if (b->parent != NULL)
|
if (b->osContainer != NULL)
|
||||||
uiParentUpdate(b->parent);
|
uiOSContainerUpdate(b->osContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,8 +269,8 @@ static void boxContainerHide(uiControl *c)
|
||||||
b->containerHid = 1;
|
b->containerHid = 1;
|
||||||
for (i = 0; i < b->len; i++)
|
for (i = 0; i < b->len; i++)
|
||||||
uiControlContainerHide(b->controls[i].c);
|
uiControlContainerHide(b->controls[i].c);
|
||||||
if (b->parent != NULL)
|
if (b->osContainer != NULL)
|
||||||
uiParentUpdate(b->parent);
|
uiOSContainerUpdate(b->osContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void boxEnable(uiControl *c)
|
static void boxEnable(uiControl *c)
|
||||||
|
@ -327,10 +328,10 @@ static void boxAppend(uiBox *ss, uiControl *c, int stretchy)
|
||||||
uiControlSethasParent(c, 1);
|
uiControlSethasParent(c, 1);
|
||||||
b->controls[b->len].c = c;
|
b->controls[b->len].c = c;
|
||||||
b->controls[b->len].stretchy = stretchy;
|
b->controls[b->len].stretchy = stretchy;
|
||||||
b->len++; // must be here for parent updates to work
|
b->len++; // must be here for OS container updates to work
|
||||||
if (b->osContainer != NULL) {
|
if (b->osContainer != NULL) {
|
||||||
uiControlSetOSContainer(b->controls[b->len - 1].c, b->osContainer);
|
uiControlSetOSContainer(b->controls[b->len - 1].c, b->osContainer);
|
||||||
uiParentUpdate(b->parent);
|
uiOSContainerUpdate(b->osContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +350,7 @@ static void boxDelete(uiBox *ss, uintmax_t index)
|
||||||
uiControlSetHasParent(removed, 0);
|
uiControlSetHasParent(removed, 0);
|
||||||
if (b->osContainer != NULL) {
|
if (b->osContainer != NULL) {
|
||||||
uiControlSetOSContainer(removed, NULL);
|
uiControlSetOSContainer(removed, NULL);
|
||||||
uiParentUpdate(b->parent);
|
uiOSContainerUpdate(b->osContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,8 +366,8 @@ static void boxSetPadded(uiBox *ss, int padded)
|
||||||
box *b = (box *) ss;
|
box *b = (box *) ss;
|
||||||
|
|
||||||
b->padded = padded;
|
b->padded = padded;
|
||||||
if (b->parent != NULL)
|
if (b->osContainer != NULL)
|
||||||
uiParentUpdate(b->parent);
|
uiOSContainerUpdate(b->osContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiBox *uiNewHorizontalBox(void)
|
uiBox *uiNewHorizontalBox(void)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# 22 april 2015
|
||||||
|
|
||||||
|
testCFILES = \
|
||||||
|
test/main.c \
|
||||||
|
test/spaced.c
|
||||||
|
|
||||||
|
testHFILES = \
|
||||||
|
test/test.h
|
|
@ -0,0 +1,8 @@
|
||||||
|
// 22 april 2015
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
printf("hello, world %p\n", uiMain);
|
||||||
|
return 0;
|
||||||
|
}
|
11
new/uipriv.h
11
new/uipriv.h
|
@ -0,0 +1,11 @@
|
||||||
|
// 6 april 2015
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
extern uiInitOptions options;
|
||||||
|
|
||||||
|
extern void *uiAlloc(size_t, const char *);
|
||||||
|
#define uiNew(T) ((T *) uiAlloc(sizeof (T), #T ))
|
||||||
|
extern void *uiRealloc(void *, size_t, const char *);
|
||||||
|
extern void uiFree(void *);
|
||||||
|
|
||||||
|
extern void complain(const char *, ...);
|
Loading…
Reference in New Issue