Make GMP optional for the examples
This commit is contained in:
1 parent
87183573ce
commit
dde090d4b0
3 files changed
+25
-5
No files matched your search
+11
-5
@@ -1,18 +1,24 @@
|
|||||||
CC=cc -std=c99
|
CC=cc -std=c99
|
||||||
CFLAGS=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wno-unused-function
|
CFLAGS=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wno-unused-function
|
||||||
CPPFLAGS=-I..
|
GMP_DIR=
|
||||||
LDFLAGS=-pthread -lgmp
|
CPPFLAGS=-I.. -I$(GMP_DIR)/include
|
||||||
|
LDFLAGS=-pthread -L$(GMP_DIR)/lib
|
||||||
RM=rm -f
|
RM=rm -f
|
||||||
|
|
||||||
.SUFFIXES: .c .exe
|
.SUFFIXES: .c .exe
|
||||||
|
|
||||||
.c.exe:
|
.c.exe:
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `cat config` $< -o $@
|
||||||
|
|
||||||
all:
|
all: config
|
||||||
$(MAKE) `ls ex-*.c|sed -e 's/\.c/\.exe/g'`
|
$(MAKE) `ls ex-*.c|sed -e 's/\.c/\.exe/g'`
|
||||||
|
|
||||||
|
config:
|
||||||
|
printf "#include <gmp.h>\nint main(void){mpz_t z; mpz_init(z); return 0;}\n" > config-test.c
|
||||||
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -lgmp config-test.c -o config-test.exe 2> /dev/null && echo "-DHAVE_GMP=1 -lgmp" > config || echo "-DHAVE_GMP=0" > config
|
||||||
|
$(RM) config-test.*
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) *.exe *.s *~ *.o ./a.dat
|
$(RM) *.exe *.s *~ *.o ./a.dat config
|
||||||
|
|
||||||
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#if HAVE_GMP
|
||||||
|
|
||||||
#include <gmp.h>
|
#include <gmp.h>
|
||||||
|
|
||||||
#include "m-array.h"
|
#include "m-array.h"
|
||||||
@@ -35,3 +37,8 @@ int main(void)
|
|||||||
array_mpz_clear(a);
|
array_mpz_clear(a);
|
||||||
mpz_clear(z);
|
mpz_clear(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Nothing to do
|
||||||
|
int main(void) { return 0; }
|
||||||
|
#endif
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#if HAVE_GMP
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gmp.h>
|
#include <gmp.h>
|
||||||
|
|
||||||
@@ -61,3 +63,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
} /* All variables are automatically cleared beyond this point */
|
} /* All variables are automatically cleared beyond this point */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Nothing to do
|
||||||
|
int main(void) { return 0; }
|
||||||
|
#endif
|
||||||
Reference in new issue
Block a user