Static content management system for mirroring directory structure on the web.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.4 KiB

5 years ago
# Makefile 1.2 (GNU Make 3.81; MacOSX gcc 4.2.1; MacOSX MinGW 4.3.0)
PROJ := MakeIndex
VA := 1
VB := 1
5 years ago
# dirs
SDIR := src
TDIR := test
GDIR := build
BDIR := bin
BACK := backup
5 years ago
DDIR := doc
PREFIX:= /usr/local
# files in bdir
INST := $(PROJ)-$(VA)_$(VB)
5 years ago
# extra stuff we should back up
5 years ago
# John Graham-Cumming:
# rwildcard is a recursive wildcard
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
5 years ago
# select all automatically
SRCS := $(call rwildcard, $(SDIR), *.c) # or *.java
TEST := $(call rwildcard, $(TDIR), *.c)
H := $(call rwildcard, $(SDIR), *.h) $(call rwildcard, $(TDIR), *.h)
OBJS := $(patsubst $(SDIR)/%.c, $(GDIR)/%.o, $(SRCS)) # or *.class
TOBJS := $(patsubst $(TDIR)/%.c, $(GDIR)/$(TDIR)/%.o, $(TEST))
DOCS := $(patsubst $(SDIR)/%.c, $(DDIR)/%.html, $(SRCS))
5 years ago
CC := gcc # /usr/local/i386-mingw32-4.3.0/bin/i386-mingw32-gcc javac nxjc
CF := -Wall -Wextra -Wno-format-y2k -W -Wstrict-prototypes \
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings \
-Wswitch -Wshadow -Wcast-align -Wbad-function-cast -Wchar-subscripts -Winline \
-Wnested-externs -Wredundant-decls -O3 -ffast-math -funroll-loops -pedantic -ansi # or -std=c99 -mwindows or -g:none -O -verbose -d $(BDIR) $(SDIR)/*.java -Xlint:unchecked -Xlint:deprecation
OF := # -framework OpenGL -framework GLUT or -lglut -lGLEW
CDOC := cdoc
5 years ago
# props Jakob Borg and Eldar Abusalimov
# $(ARGS) is all the extra arguments
# $(BRGS) is_all_the_extra_arguments
ifeq (backup, $(firstword $(MAKECMDGOALS)))
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
BRGS := $(subst $(SPACE),_,$(ARGS))
ifneq (,$(BRGS))
BRGS := -$(BRGS)
$(eval $(ARGS):;@:)
5 years ago
# compiles the programme by default
5 years ago
default: $(BDIR)/$(PROJ) $(DOCS)
# . . . success; executable is in $(BDIR)/$(PROJ)
5 years ago
# linking
@mkdir -p $(BDIR)
5 years ago
$(CC) $(CF) $(OF) $(OBJS) -o $@
# compiling
$(OBJS): $(GDIR)/%.o: $(SDIR)/%.c $(H)
@mkdir -p $(GDIR)
$(CC) $(CF) -c $(SDIR)/$*.c -o $@
$(TOBJS): $(GDIR)/$(TDIR)/%.o: $(TDIR)/%.c $(H)
@mkdir -p $(GDIR)
@mkdir -p $(GDIR)/$(TDIR)
$(CC) $(CF) -c $(TDIR)/$*.c -o $@
$(DOCS): $(DDIR)/%.html: $(SDIR)/%.c $(SDIR)/%.h
@mkdir -p $(DDIR)
-cat $^ | $(CDOC) > $@
5 years ago
# phoney targets
.PHONY: setup clean backup icon install uninstall
5 years ago
-rm -f $(OBJS) $(TOBJS) $(DOCS)
-rm -rf $(BDIR)/$(TDIR)
@mkdir -p $(BACK)
5 years ago
zip $(BACK)/$(INST)-`date +%Y-%m-%dT%H%M%S`$(BRGS).zip readme.txt gpl.txt copying.txt Makefile $(SRCS) $(TEST) $(H) $(SDIR)/$(ICON) $(EXTRA)
#git commit -am "$(ARGS)"
5 years ago
icon: default
# . . . setting icon on a Mac.
cp $(MDIR)/$(ICON) $(BDIR)/$(ICON)
-sips --addIcon $(BDIR)/$(ICON)
-DeRez -only icns $(BDIR)/$(ICON) > $(BDIR)/$(RSRC)
-Rez -append $(BDIR)/$(RSRC) -o $(BDIR)/$(PROJ)
-SetFile -a C $(BDIR)/$(PROJ)
setup: default icon
@mkdir -p $(BDIR)/$(INST)
cp $(BDIR)/$(PROJ) readme.txt gpl.txt copying.txt $(BDIR)/$(INST)
5 years ago
rm -f $(BDIR)/$(INST)-MacOSX.dmg
# or rm -f $(BDIR)/$(INST)
hdiutil create $(BDIR)/$(INST)-MacOSX.dmg -volname "$(PROJ) $(VA).$(VB)" -srcfolder $(BDIR)/$(INST)
# or zip $(BDIR)/$(INST) -r $(BDIR)/$(INST)
rm -R $(BDIR)/$(INST)
5 years ago
install: default
@mkdir -p $(DESTDIR)$(PREFIX)/bin
cp $(BDIR)/$(PROJ) $(DESTDIR)$(PREFIX)/bin/$(PROJ)
rm -f $(DESTDIR)$(PREFIX)/bin/$(PROJ)