Permalink
Browse files

Merge pull request #8 from rctay/rc/mingw

improved support for building on mingw
  • Loading branch information...
2 parents 2a5daec + 43c766e commit 8a10734900d74ca191afb15f794053f3370fbcb3 @jgm jgm committed Jan 31, 2012
Showing with 90 additions and 7 deletions.
  1. +15 −7 Makefile
  2. +75 −0 peg-exe-ext.patch
View
@@ -1,24 +1,33 @@
-ALL : markdown
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+ifneq (,$(findstring MINGW,$(uname_S)))
+ X = .exe
+endif
-PROGRAM=markdown
+export X
+
+PROGRAM=markdown$(X)
CFLAGS ?= -Wall -O3 -ansi
OBJS=markdown_parser.o markdown_output.o markdown_lib.o
PEGDIR_ORIG=peg-0.1.4
PEGDIR=peg
-LEG=$(PEGDIR)/leg
+LEG=$(PEGDIR)/leg$(X)
+PKG_CONFIG = pkg-config
+
+ALL : $(PROGRAM)
$(PEGDIR):
cp -r $(PEGDIR_ORIG) $(PEGDIR) ; \
- patch -p1 < peg-memory-fix.patch
+ patch -p1 < peg-memory-fix.patch ; \
+ patch -p1 < peg-exe-ext.patch
$(LEG): $(PEGDIR)
CC=gcc make -C $(PEGDIR)
%.o : %.c markdown_peg.h
- $(CC) -c `pkg-config --cflags glib-2.0` $(CFLAGS) -o $@ $<
+ $(CC) -c `$(PKG_CONFIG) --cflags glib-2.0` $(CFLAGS) -o $@ $<
$(PROGRAM) : markdown.c $(OBJS)
- $(CC) `pkg-config --cflags glib-2.0` `pkg-config --libs glib-2.0` $(CFLAGS) -o $@ $(OBJS) $<
+ $(CC) `$(PKG_CONFIG) --cflags glib-2.0` $(CFLAGS) -o $@ $< $(OBJS) `$(PKG_CONFIG) --libs glib-2.0`
markdown_parser.c : markdown_parser.leg $(LEG) markdown_peg.h parsing_functions.c utility_functions.c
$(LEG) -o $@ $<
@@ -37,4 +46,3 @@ test: $(PROGRAM)
leak-check: $(PROGRAM)
valgrind --leak-check=full ./markdown README
-
View
@@ -0,0 +1,75 @@
+2271467 peg/Makefile: use variables for binary file names (Tay Ray Chuan, Tue Jan 31 15:33:20 2012 +0800)
+diff --git a/peg-0.1.4/Makefile b/peg-0.1.4/Makefile
+index bc45e64..712e57e 100644
+--- a/peg-0.1.4/Makefile
++++ b/peg-0.1.4/Makefile
+@@ -1,16 +1,19 @@
++PEG = peg$(X)
++LEG = leg$(X)
++
+ CFLAGS = -g -Wall $(OFLAGS) $(XFLAGS)
+ OFLAGS = -O3 -DNDEBUG
+ #OFLAGS = -pg
+
+ OBJS = tree.o compile.o
+
+-all : peg leg
++all : $(PEG) $(LEG)
+
+-peg : peg.o $(OBJS)
++$(PEG) : peg.o $(OBJS)
+ $(CC) $(CFLAGS) -o $@-new peg.o $(OBJS)
+ mv $@-new $@
+
+-leg : leg.o $(OBJS)
++$(LEG) : leg.o $(OBJS)
+ $(CC) $(CFLAGS) -o $@-new leg.o $(OBJS)
+ mv $@-new $@
+
+@@ -18,28 +21,28 @@ ROOT =
+ PREFIX = /usr/local
+ BINDIR = $(ROOT)$(PREFIX)/bin
+
+-install : $(BINDIR)/peg $(BINDIR)/leg
++install : $(BINDIR)/$(PEG) $(BINDIR)/$(LEG)
+
+ $(BINDIR)/% : %
+ cp -p $< $@
+ strip $@
+
+ uninstall : .FORCE
+- rm -f $(BINDIR)/peg
+- rm -f $(BINDIR)/leg
++ rm -f $(BINDIR)/$(PEG)
++ rm -f $(BINDIR)/$(LEG)
+
+ peg.o : peg.c peg.peg-c
+
+ %.peg-c : %.peg
+-# ./peg -o $@ $<
++# ./$(PEG) -o $@ $<
+
+ leg.o : leg.c
+
+ leg.c : leg.leg
+-# ./leg -o $@ $<
++# ./$(LEG) -o $@ $<
+
+-check : peg .FORCE
+- ./peg < peg.peg > peg.out
++check : $(PEG) .FORCE
++ ./$(PEG) < peg.peg > peg.out
+ diff peg.peg-c peg.out
+ rm peg.out
+
+@@ -51,8 +54,8 @@ clean : .FORCE
+ $(SHELL) -ec '(cd examples; $(MAKE) $@)'
+
+ spotless : clean .FORCE
+- rm -f peg
+- rm -f leg
++ rm -f $(PEG)
++ rm -f $(LEG)
+ $(SHELL) -ec '(cd examples; $(MAKE) $@)'
+
+ .FORCE :

0 comments on commit 8a10734

Please sign in to comment.