Assembled a new make system. Not quite working the way I'd like yet, but definitely a start.

This commit is contained in:
Pietro Gagliardi 2015-10-16 20:55:09 -04:00
parent ab97e26efc
commit 790edf0df8
11 changed files with 201 additions and 161 deletions

View File

@ -1,66 +0,0 @@
# 22 april 2015
OUTBASE = new
OUTDIR = out
OBJDIR = .obj
IDLFILES = \
$(baseIDLFILES)
xHFILES = \
$(baseHFILES)
OFILES = \
$(baseCFILES:%.c=$(OBJDIR)/%.o) \
$(baseMFILES:%.m=$(OBJDIR)/%.o) \
$(baseRCFILES:%.rc=$(OBJDIR)/%.o)
xCFLAGS = \
-g \
-Wall -Wextra \
-Wno-unused-parameter \
-Wno-switch \
--std=c99 \
$(CFLAGS) \
$(archmflag) \
$(baseCFLAGS)
# windres doesn't support -m
xRCFLAGS = \
$(RCFLAGS) \
$(baseRCFLAGS)
xLDFLAGS = \
-g \
$(LDFLAGS) \
$(archmflag) \
$(baseLDFLAGS)
OUT = $(OUTDIR)/$(OUTBASE)$(baseSUFFIX)
$(OUT): $(OFILES) | $(OUTDIR)/.phony
@$(CC) -o $(OUT) $(OFILES) $(xLDFLAGS)
@echo ====== Linked $(OUT)
.SECONDEXPANSION:
$(OBJDIR)/%.o: %.c $(xHFILES) | $$(dir $$@).phony
@$(CC) -o $@ -c $< $(xCFLAGS)
@echo ====== Compiled $<
$(OBJDIR)/%.o: %.m $(xHFILES) | $$(dir $$@).phony
@$(CC) -o $@ -c $< $(xCFLAGS)
@echo ====== Compiled $<
$(OBJDIR)/%.o: %.rc $(xHFILES) | $$(dir $$@).phony
@$(RC) $(xRCFLAGS) $< $@
@echo ====== Compiled $<
# see http://www.cmcrossroads.com/article/making-directories-gnu-make
%/.phony:
@mkdir -p $(dir $@)
@touch $@
.PRECIOUS: %/.phony
clean:
rm -rf $(OUTDIR) $(OBJDIR) z*
.PHONY: clean

56
GNUbaserules.mk Normal file
View File

@ -0,0 +1,56 @@
# 16 october 2015
OUTDIR = out
OBJDIR = .obj
OFILES = \
$(subst /,_,$(CFILES)) \
$(subst /,_,$(MFILES)) \
$(subst /,_,$(RCFILES))
OFILES := $(OFILES:%=$(OBJDIR)/%.o)
CFLAGS += \
-g \
-Wall -Wextra \
-Wno-unused-parameter \
-Wno-switch \
--std=c99
LDFLAGS += \
-g
ifeq ($(ARCH),386)
CFLAGS += -m32
LDFLAGS += -m32
else ifeq ($(ARCH),amd64)
CFLAGS += -m64
LDFLAGS += -m64
endif
OUT = $(OUTDIR)/$(NAME)$(SUFFIX)
$(OUT): $(OFILES) | $(OUTDIR)
@$(CC) -o $(OUT) $(OFILES) $(LDFLAGS)
@echo ====== Linked $(OUT)
.SECONDEXPANSION:
$(OBJDIR)/%.c.o: $$(subst _,/,%).c $(HFILES) | $(OBJDIR)
@$(CC) -o $@ -c $< $(CFLAGS)
@echo ====== Compiled $<
$(OBJDIR)/%.m.o: $$(subst _,/,%).m $(HFILES) | $(OBJDIR)
@$(CC) -o $@ -c $< $(CFLAGS)
@echo ====== Compiled $<
$(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR)
@$(RC) $(RCFLAGS) $< $@
@echo ====== Compiled $<
$(OBJDIR) $(OUTDIR):
@mkdir -p $@
clean:
rm -rf $(OBJDIR) $(OUTDIR)
.PHONY: clean

View File

@ -1,51 +1,38 @@
# 22 april 2015
# 16 october 2015
# silence entering/leaving messages
MAKEFLAGS += --no-print-directory
# MAME does this so :/
ifeq ($(OS),Windows_NT)
OS = windows
OS = windows
endif
ifndef OS
UNAME = $(shell uname -s)
ifeq ($(UNAME),Darwin)
OS = darwin
else
OS = unix
endif
UNAME = $(shell uname -s)
ifeq ($(UNAME),Darwin)
OS = darwin
else
OS = unix
endif
endif
include $(OS)/GNUmakeinc.mk
ifndef ARCH
UNAME = $(shell uname -m)
ifeq ($(UNAME),x86_64)
ARCH = amd64
else ifeq ($(UNAME),i686)
ARCH = 386
else
ARCH = default
endif
endif
baseHFILES = \
ui.h \
uipriv.h \
ui_$(OS).h \
$(osHFILES)
libui:
@$(MAKE) -f GNUmakefile.libui OS=$(OS) ARCH=$(ARCH)
baseCFILES = \
areaevents.c \
control.c \
matrix.c \
menu.c \
ptrarray.c \
shouldquit.c \
types.c \
$(osCFILES)
clean:
@$(MAKE) -f GNUmakefile.libui OS=$(OS) ARCH=$(ARCH) clean
baseMFILES = $(osMFILES)
baseRCFILES = $(osRCFILES)
baseCFLAGS = $(osCFLAGS)
baseLDFLAGS = \
-shared \
$(osLDWarnUndefinedFlags) \
$(osLDFLAGS)
baseRCFLAGS = $(osRCFLAGS)
baseSUFFIX = $(osLIBSUFFIX)
include GNUbase.mk
test: $(OUT)
@$(MAKE) -f GNUmaketest.mk osLIB=$(OUT) osEXESUFFIX=$(osEXESUFFIX) CC=$(CC) archmflag=$(archmflag)
.PHONY: test
test: libui
@$(MAKE) -f GNUmakefile.test OS=$(OS) ARCH=$(ARCH)

16
GNUmakefile.libui Normal file
View File

@ -0,0 +1,16 @@
# 16 october 2015
include common/GNUmakeinc.mk
include $(OS)/GNUmakeinc.mk
HFILES += \
ui.h \
ui_$(OS).h
NAME = libui
LDFLAGS += \
-shared \
-Wl,-soname,$(NAME)$(SUFFIX).0
include GNUbaserules.mk

41
GNUmakefile.test Normal file
View File

@ -0,0 +1,41 @@
# 16 october 2015
include test/GNUmakeinc.mk
HFILES += \
ui.h
NAME = test
SUFFIX =
ifeq ($(OS),windows)
SUFFIX = .exe
endif
# TODO split out this logic somehow
ifeq ($(OS),windows)
ifeq ($(ARCH),amd64)
ifndef CC
CC = x86_64-w64-mingw32-gcc
endif
ifndef RC
RC = x86_64-w64-mingw32-windres
endif
else ifeq ($(ARCH),386)
ifndef CC
CC = i686-w64-mingw32-gcc
endif
ifndef RC
RC = i686-w64-mingw32-windres
endif
else ifneq ($(ARCH),default)
$(error [FAIL] unknown architecture $(ARCH))
endif
LDFLAGS += out/libui.dll
else ifeq ($(OS),darwin)
LDFLAGS += out/libui.dylib
else
LDFLAGS += out/libui.so
endif
include GNUbaserules.mk

View File

@ -1,15 +0,0 @@
# 22 april 2015
# should never be invoked directly, only ever from the main makefile
include test/GNUmakeinc.mk
baseHFILES = \
$(testHFILES)
baseCFILES = $(testCFILES)
baseCFLAGS = $(testCFLAGS)
baseLDFLAGS = $(osLIB) $(testLDFLAGS)
baseSUFFIX = $(osEXESUFFIX)
include GNUbase.mk

13
common/GNUmakeinc.mk Normal file
View File

@ -0,0 +1,13 @@
# 16 october 2015
CFILES += \
common/areaevents.c \
common/control.c \
common/matrix.c \
common/menu.c \
common/ptrarray.c \
common/shouldquit.c \
common/types.c
HFILES += \
common/uipriv.h

View File

@ -1,6 +1,6 @@
# 28 april 2015
osMFILES = \
MFILES += \
darwin/alloc.m \
darwin/area.m \
darwin/areaevents.m \
@ -29,26 +29,24 @@ osMFILES = \
darwin/util.m \
darwin/window.m
osHFILES = \
HFILES += \
darwin/uipriv_darwin.h
osCFLAGS = \
CFLAGS += \
-D_UI_EXTERN='__attribute__((visibility("default"))) extern' \
-fvisibility=hidden \
-mmacosx-version-min=10.7 -DMACOSX_DEPLOYMENT_TARGET=10.7
osLDFLAGS = \
-fvisibility=hidden \
-mmacosx-version-min=10.7 -lobjc -framework Foundation -framework AppKit
-mmacosx-version-min=10.7 \
-DMACOSX_DEPLOYMENT_TARGET=10.7
LDFLAGS += \
-fvisibility=hidden \
-mmacosx-version-min=10.7 \
-lobjc \
-framework Foundation \
-framework AppKit
# on warning about undefined symbols:
# the gcc flags don't work with Apple's linker
# fortunately, we don't need any; Apple's linker warns about undefined symbols in -shared builds!
osLDWarnUndefinedFlags =
osLIBSUFFIX = .dylib
osEXESUFFIX =
ifeq ($(ARCH),386)
archmflag = -m32
else
archmflag = -m64
endif
SUFFIX = .dylib

View File

@ -1,6 +1,6 @@
# 22 april 2015
testCFILES = \
CFILES += \
test/drawtests.c \
test/main.c \
test/menus.c \
@ -13,5 +13,5 @@ testCFILES = \
test/page7.c \
test/spaced.c
testHFILES = \
HFILES += \
test/test.h

View File

@ -1,6 +1,6 @@
# 22 april 2015
osCFILES = \
CFILES += \
unix/alloc.c \
unix/area.c \
unix/box.c \
@ -27,22 +27,23 @@ osCFILES = \
unix/util.c \
unix/window.c
osHFILES = \
HFILES += \
unix/uipriv_unix.h
# thanks ebassi in irc.gimp.net/#gtk+
osCFLAGS = \
CFLAGS += \
-D_UI_EXTERN='__attribute__((visibility("default"))) extern' \
-fvisibility=hidden \
-fPIC \
`pkg-config --cflags gtk+-3.0`
osLDFLAGS = \
LDFLAGS += \
-fvisibility=hidden \
-fPIC \
`pkg-config --libs gtk+-3.0` -lm
osLDWarnUndefinedFlags = -Wl,--no-undefined -Wl,--no-allow-shlib-undefined
# flags for warning on undefined symbols
LDFLAGS += \
-Wl,--no-undefined -Wl,--no-allow-shlib-undefined
osLIBSUFFIX = .so
osEXESUFFIX =
SUFFIX = .so

View File

@ -1,6 +1,6 @@
# 22 april 2015
osCFILES = \
CFILES += \
windows/alloc.c \
windows/area.c \
windows/box.c \
@ -36,34 +36,43 @@ osCFILES = \
windows/utilwin.c \
windows/window.c
osHFILES = \
HFILES += \
windows/compilerver.h \
windows/resources.h \
windows/uipriv_windows.h \
windows/winapi.h
osRCFILES = \
RCFILES += \
windows/resources.rc
# thanks ebassi in irc.gimp.net/#gtk+
osCFLAGS = \
CFLAGS += \
-D_UI_EXTERN='__declspec(dllexport) extern'
osLDFLAGS = \
LDFLAGS += \
-static-libgcc \
-luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 -ld2d1 -lole32 -loleaut32 -loleacc -luuid
osLDWarnUndefinedFlags = -Wl,--no-undefined -Wl,--no-allow-shlib-undefined
# warnings on undefined symbols
LDFLAGS += \
-Wl,--no-undefined -Wl,--no-allow-shlib-undefined
osLIBSUFFIX = .dll
osEXESUFFIX = .exe
SUFFIX = .dll
ifeq ($(ARCH),amd64)
CC = x86_64-w64-mingw32-gcc
RC = x86_64-w64-mingw32-windres
archmflag = -m64
else
CC = i686-w64-mingw32-gcc
RC = i686-w64-mingw32-windres
archmflag = -m32
ifndef CC
CC = x86_64-w64-mingw32-gcc
endif
ifndef RC
RC = x86_64-w64-mingw32-windres
endif
else ifeq ($(ARCH),386)
ifndef CC
CC = i686-w64-mingw32-gcc
endif
ifndef RC
RC = i686-w64-mingw32-windres
endif
else ifneq ($(ARCH),default)
$(error [FAIL] unknown architecture $(ARCH))
endif