aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2016-12-21 20:49:06 +0100
committerJ08nY2016-12-21 20:49:44 +0100
commitca55e2403048485accda8bbf63e190368206c9b5 (patch)
tree0f7743f501889a7faef853a8e27779d8acdf66de
parentb91bf574551fe9ac06316123b92d0b6c688c3389 (diff)
downloadecgen-ca55e2403048485accda8bbf63e190368206c9b5.tar.gz
ecgen-ca55e2403048485accda8bbf63e190368206c9b5.tar.zst
ecgen-ca55e2403048485accda8bbf63e190368206c9b5.zip
-rw-r--r--Makefile37
-rw-r--r--ecgen.c6
-rw-r--r--points.c24
-rw-r--r--points.h23
-rw-r--r--sea.c20
-rw-r--r--sea.h19
6 files changed, 68 insertions, 61 deletions
diff --git a/Makefile b/Makefile
index 1b597df..e614309 100644
--- a/Makefile
+++ b/Makefile
@@ -1,34 +1,39 @@
CC=gcc
GP2C=gp2c
-CFLAGS=-g -O3 -Wall
-GP_CFLAGS=-g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/include/x86_64-linux-gnu"
-STATIC_CFLAGS=-o points.so -shared -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -Wl,-shared -Wl,-z,relro points.o -lc -lm -L/usr/lib/x86_64-linux-gnu -lpari
+
+INCLUDES=-I.
+
+CFLAGS=$(INCLUDES) -g -O3 -Wall
+GP_CFLAGS=$(INCLUDES) -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC
GPFLAGS=-g
+
LIBS=-lpari -lreadline -ltermcap
-GP = points.c sea.c
-OBJ = points.o sea.o
-DEPS = points.h sea.h
+GP = points sea
+GPC = $(addsuffix .c, $(GP))
+GPO = $(addsuffix .o, $(GP))
+GPH = $(addsuffix .h, $(GP))
all: ecgen
-ecgen: $(OBJ)
- $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+ecgen: ecgen.o $(GPO)
+ $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
-gp2c: $(GP)
+gp2c: $(GPC)
-$(OBJ): $(GP)
- $(CC) -c -o $@ $< $(GP_CFLAGS)
+$(GPO): $(GPC) $(GPH)
+ $(CC) $(GP_CFLAGS) -c -o $@ $< $(LIBS)
-%.o: %.c
- $(CC) -c -o $@ $< $(CFLAGS)
+%.o: %.c $(GPH)
+ $(CC) $(CFLAGS) -c -o $@ $< $(LIBS)
-%.c: %.gp
- $(GP2C) -o $(basename $@).gp.c $< $(GPFLAGS)
- { sed -n '/\/\*End of prototype\*\//q;p'; cat >"$@"; } < $(basename $@).gp.c > $(basename $@).h
+%.h %.c: %.gp
+ $(GP2C) $*.gp $(GPFLAGS) 2>/dev/null | { sed -u '/\/\*End of prototype\*\//q' >"$*.h"; echo '#include "$*.h"' >"$*.c"; cat >>"$*.c"; }
.PHONY: clean
clean:
+ rm -f ecgen
rm *.o
+ rm -f $(GPH)
diff --git a/ecgen.c b/ecgen.c
index 202f839..bf8c1ca 100644
--- a/ecgen.c
+++ b/ecgen.c
@@ -4,8 +4,8 @@
#include <stdio.h>
#include <readline/readline.h>
-#include "points.c"
-#include "sea.c"
+#include "points.h"
+#include "sea.h"
char *readHex() {
char *r = readline(NULL);
@@ -38,7 +38,7 @@ int main(int argc, char * argv[]) {
init_sea();
pari_init( 1e9, 1e8 );
- default0("datadir","./data");
+ //default0("datadir","./data");
char *sp = readHex();
char *sa = readHex();
diff --git a/points.c b/points.c
index 1266d56..9fe5a56 100644
--- a/points.c
+++ b/points.c
@@ -1,26 +1,4 @@
-/*-*- compile-command: "cc -c -o points.o -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/include/x86_64-linux-gnu" points.c && cc -o points.so -shared -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -Wl,-shared -Wl,-z,relro points.o -lc -lm -L/usr/lib/x86_64-linux-gnu -lpari"; -*-*/
-#include <pari/pari.h>
-/*
-GP;install("init_points","v","init_points","./points.so");
-GP;install("find_point","D0,G,D0,G,D0,G,","find_point","./points.so");
-GP;install("find_points","D0,G,D0,G,D0,G,","find_points","./points.so");
-GP;install("maxprime_order","D0,G,D0,G,","maxprime_order","./points.so");
-GP;install("minprime_order","D0,G,D0,G,","minprime_order","./points.so");
-GP;install("max_order","D0,G,D0,G,","max_order","./points.so");
-GP;install("get_point","D0,G,D0,G,D0,G,","get_point","./points.so");
-GP;install("prime_orders","D0,G,D0,G,","prime_orders","./points.so");
-GP;install("get_points","D0,G,D0,G,D0,G,","get_points","./points.so");
-*/
-void init_points(void);
-GEN find_point(GEN e, GEN o, GEN n);
-GEN find_points(GEN e, GEN o, GEN p);
-GEN maxprime_order(GEN e, GEN o);
-GEN minprime_order(GEN e, GEN o);
-GEN max_order(GEN e, GEN o);
-GEN get_point(GEN e, GEN o, GEN f);
-GEN prime_orders(GEN e, GEN o);
-GEN get_points(GEN e, GEN o, GEN f);
-/*End of prototype*/
+#include "points.h"
void
init_points(void) /* void */
diff --git a/points.h b/points.h
new file mode 100644
index 0000000..302a222
--- /dev/null
+++ b/points.h
@@ -0,0 +1,23 @@
+/*-*- compile-command: "cc -c -o points.gp.o -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/include/x86_64-linux-gnu" points.gp.c && cc -o points.gp.so -shared -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -Wl,-shared -Wl,-z,relro points.gp.o -lc -lm -L/usr/lib/x86_64-linux-gnu -lpari"; -*-*/
+#include <pari/pari.h>
+/*
+GP;install("init_points","v","init_points","./points.gp.so");
+GP;install("find_point","D0,G,D0,G,D0,G,","find_point","./points.gp.so");
+GP;install("find_points","D0,G,D0,G,D0,G,","find_points","./points.gp.so");
+GP;install("maxprime_order","D0,G,D0,G,","maxprime_order","./points.gp.so");
+GP;install("minprime_order","D0,G,D0,G,","minprime_order","./points.gp.so");
+GP;install("max_order","D0,G,D0,G,","max_order","./points.gp.so");
+GP;install("get_point","D0,G,D0,G,D0,G,","get_point","./points.gp.so");
+GP;install("prime_orders","D0,G,D0,G,","prime_orders","./points.gp.so");
+GP;install("get_points","D0,G,D0,G,D0,G,","get_points","./points.gp.so");
+*/
+void init_points(void);
+GEN find_point(GEN e, GEN o, GEN n);
+GEN find_points(GEN e, GEN o, GEN p);
+GEN maxprime_order(GEN e, GEN o);
+GEN minprime_order(GEN e, GEN o);
+GEN max_order(GEN e, GEN o);
+GEN get_point(GEN e, GEN o, GEN f);
+GEN prime_orders(GEN e, GEN o);
+GEN get_points(GEN e, GEN o, GEN f);
+/*End of prototype*/
diff --git a/sea.c b/sea.c
index 1a987db..946d4f1 100644
--- a/sea.c
+++ b/sea.c
@@ -1,22 +1,4 @@
-/*-*- compile-command: "cc -c -o sea.o -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/include/x86_64-linux-gnu" sea.c && cc -o sea.so -shared -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -Wl,-shared -Wl,-z,relro sea.o -lc -lm -L/usr/lib/x86_64-linux-gnu -lpari"; -*-*/
-#include <pari/pari.h>
-/*
-GP;install("init_sea","v","init_sea","./sea.so");
-GP;install("largest_prime","D0,G,D0,G,D0,G,p","largest_prime","./sea.so");
-GP;install("smallest_prime","D0,G,D0,G,D0,G,p","smallest_prime","./sea.so");
-GP;install("all_prime","D0,G,D0,G,D0,G,p","all_prime","./sea.so");
-GP;install("small_pubkey","D0,G,D0,G,D0,G,p","small_pubkey","./sea.so");
-GP;install("print_params","vD0,G,","print_params","./sea.so");
-GP;install("print_params_pub","vD0,G,","print_params_pub","./sea.so");
-*/
-void init_sea(void);
-GEN largest_prime(GEN p, GEN a, GEN b, long prec);
-GEN smallest_prime(GEN p, GEN a, GEN b, long prec);
-GEN all_prime(GEN p, GEN a, GEN b, long prec);
-GEN small_pubkey(GEN p, GEN a, GEN b, long prec);
-void print_params(GEN curve);
-void print_params_pub(GEN curve);
-/*End of prototype*/
+#include "sea.h"
void
init_sea(void) /* void */
diff --git a/sea.h b/sea.h
new file mode 100644
index 0000000..be27ed6
--- /dev/null
+++ b/sea.h
@@ -0,0 +1,19 @@
+/*-*- compile-command: "cc -c -o sea.gp.o -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/include/x86_64-linux-gnu" sea.gp.c && cc -o sea.gp.so -shared -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -Wl,-shared -Wl,-z,relro sea.gp.o -lc -lm -L/usr/lib/x86_64-linux-gnu -lpari"; -*-*/
+#include <pari/pari.h>
+/*
+GP;install("init_sea","v","init_sea","./sea.gp.so");
+GP;install("largest_prime","D0,G,D0,G,D0,G,p","largest_prime","./sea.gp.so");
+GP;install("smallest_prime","D0,G,D0,G,D0,G,p","smallest_prime","./sea.gp.so");
+GP;install("all_prime","D0,G,D0,G,D0,G,p","all_prime","./sea.gp.so");
+GP;install("small_pubkey","D0,G,D0,G,D0,G,p","small_pubkey","./sea.gp.so");
+GP;install("print_params","vD0,G,","print_params","./sea.gp.so");
+GP;install("print_params_pub","vD0,G,","print_params_pub","./sea.gp.so");
+*/
+void init_sea(void);
+GEN largest_prime(GEN p, GEN a, GEN b, long prec);
+GEN smallest_prime(GEN p, GEN a, GEN b, long prec);
+GEN all_prime(GEN p, GEN a, GEN b, long prec);
+GEN small_pubkey(GEN p, GEN a, GEN b, long prec);
+void print_params(GEN curve);
+void print_params_pub(GEN curve);
+/*End of prototype*/