Code Monkey home page Code Monkey logo

ecgen's Introduction

ECTester

A toolkit for testing elliptic curve cryptography implementations on the JavaCard platform and in software libraries.

ecgen

A tool for generating elliptic curve domain parameters.

pyecsca

A toolkit for reverse engineering of black-box elliptic curve cryptography implementations using side-channel analysis.

minerva

A group of side-channel vulnerabilities in implementations of ECDSA in programmable smart cards and cryptographic software libraries.

seccerts

A website analysing the security certifications (CC & FIPS 140) landscape, presenting machine readable data extracted from thousands of certificates.

ct-tools

A website collecting constant-timeness analysis tools. Now contains more than 48 tools, and includes tutorials for some of them.




Feel free to contribute to any of these projects, they are open-source after all!

ecgen's People

Contributors

catap avatar j08ny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ecgen's Issues

Speed up generating a curve with given order

For generating a curve with a given composite order, factorizing the order and calling the addprimes function with all prime factors of the order during the initialization phase can greatly speed up the calculation of bnfisintnorm.

Does this option work? --threads=NUM

This option --threads=NUM does not fire multiple threads for me.
Is it a compile flag to enable?

Linux:
ecgen 0.7.6
Compiled with: GP/PARI CALCULATOR Version 2.15.2 (released)

Example:
./ecgen --fp -m 16g --threads=8 -v -k 1 -p -r 1024 -o ../../../../egen_ec_curves/ec1024_2.txt

Thanks

Anomalous curve generation with given order

Hey,

I was trying to generate an anomalous curve with given order but the tool is replying that two generation options can not be active at the same time.
I would like to try and implement that function but am having a problem following the logic in the source code. Would you point me to where that limitation is set so I might submit a pull request.

Vagueness when generating prime-order curves from a chosen prime.

I am trying to gen curves with a known prime field but the program seems to reject the prime with no hint as to what is wrong.

for example:
./ecgen -d data/ --fp 160 -p --metadata

[
p: 0xffffffffffffffffffffffffffffffff7fffffff
p: < just asks for a different prime? why though?

undefined reference to "polisirreducible"

OS: Ubuntu 20.04.1 LTS

steps to reproduce:

apt install lib libpari-dev
git clone https://github.com/J08nY/ecgen.git
cd ecgen
make

result:

...
gen/field.c: In function ‘field_gen_input’:
gen/field.c:88:9: warning: implicit declaration of function ‘polisirreducible’; did you mean ‘isirreducible’? [-Wimplicit-function-declaration]
   88 |    if (!polisirreducible(poly)) {
      |         ^~~~~~~~~~~~~~
      |         isirreducible
...
field.c:(.text+0x6d7): undefined reference to `polisirreducible'
collect2: error: ld returned 1 exit status

changing to isirreducible seems to work but I don't know if that is the correct function to use.

timeout option leaks file descriptors

When a timeout is hit, during factorization of curve order/SEA or something, a file descriptor is leaked:

  ***   Warning: I/O: leaked file descriptor (0): /tmp/MPQS-1000-28669/LPNEW.
  ***   Warning: I/O: leaked file descriptor (0): /tmp/MPQS-1000-28669/FNEW.

Should find a way to not do this.

Linking error on Arch Linux

Compiling on Arch Linux using make gives error like this:

cc -I. -I../lib -DNDEBUG -O2 -DGIT_COMMIT=\"d523dd7\" -Wall -o ecgen ecgen.o cm/anomalous.o cm/cm_any.o cm/cm.o cm/cm_prime.o cm/p1363.o cm/supersingular.o exhaustive/ansi.o exhaustive/arg.o exhaustive/brainpool.o exhaustive/brainpool_rfc.o exhaustive/check.o exhaustive/exhaustive.o gen/curve.o gen/equation.o gen/field.o gen/gens.o gen/hex.o gen/metadata.o gen/order.o gen/point.o gen/seed.o invalid/invalid.o invalid/invalid_thread.o io/cli.o io/input.o io/output.o math/koblitz.o math/poly.o math/subgroup.o math/twists.o misc/config.o misc/types.o obj/curve.o obj/point.o obj/subgroup.o util/bits.o util/memory.o util/random.o util/str.o util/timeout.o -L../lib/parson -L../lib/sha1 -L../lib/pari  -lrt -lpari -lpthread -lparson -lsha1
/usr/bin/ld: gen/gens.o: in function `gens_get_embedding':
gens.c:(.text+0x885): undefined reference to `order'
/usr/bin/ld: gen/gens.o: in function `gens_check_embedding':
gens.c:(.text+0x933): undefined reference to `order'
collect2: error: ld returned 1 exit status

ecgen/src/gen/gens.c

Lines 105 to 107 in d523dd7

GEN gens_get_embedding(GEN prime, GEN generator_order) {
return order(mkintmod(prime, generator_order));
}

Current pari/gp version on Arch Linux is 2.15.1-1, so I tried to compiled it on Debian 11 too and it works. Maybe this comes some breaking changes from pari/gp, but I can't find the order function in the documentation of pari 2.13.0.

Link error using PARI/GP 2.13.0

I'm building the latest ecgen tarball against PARI/GP 2.13.0. PARI/GP 2.13.0 was released in January 2021.

The build for ecgen is failing during link with:

/usr/bin/ld: invalid/invalid.o: in function `invalid_do':
invalid.c:(.text+0x68f): undefined reference to `pari_thread_sync'
/usr/bin/ld: gen/field.o: in function `field_gen_input':
field.c:(.text+0x673): undefined reference to `isirreducible'
collect2: error: ld returned 1 exit status

The first sign of trouble was:

invalid/invalid.c: In function 'invalid_curves_threaded':
invalid/invalid.c:242:2: warning: implicit declaration of function 'pari_thread_sync';
did you mean 'pari_thread_start'? [-Wimplicit-function-declaration]
  242 |  pari_thread_sync();
      |  ^~~~~~~~~~~~~~~~
      |  pari_thread_start

and

gen/field.c: In function 'field_gen_input':
gen/field.c:87:9: warning: implicit declaration of function 'isirreducible';
did you mean 'polisirreducible'? [-Wimplicit-function-declaration]
   87 |    if (!isirreducible(poly)) {
      |         ^~~~~~~~~~~~~
      |         polisirreducible

Here is the Developer Guide for PARI/GP 2.13.0. Searching the manual does not show the functions.

Additionally, searching headers for the functions return no relevant hits:

$ grep -IR pari_thread_sync ~/ok2delete/include
$

$ grep -IR isirreducible ~/ok2delete/include
/home/test/ok2delete/include/pari/paridecl.h:long    polisirreducible(GEN x);
$

I'm guessing the PARI/GP API has changed a bit.

ANSI X9.62 support

Thanks for sharing the tool and code. Anyway, I tried to generate the ANSI X9.62 but got error "Error generating a curve. state = 2"

This is the command that I used. ./ecgen --fp -p -r -s -u 192

Thanks again

NUMS curves

Is it possible to incorporate the formulas specified in the NUMS specification?
The specified formulas can be found at the following sources:

IETF Draft: https://datatracker.ietf.org/doc/html/draft-black-numscurves-02
Research Paper: https://eprint.iacr.org/2014/130.pdf

I'm currently conducting research, and the process of determining the value of b for a pseudo Mersenne prime is computationally demanding.

build issue on Mac OS X

When I want to build I got this error:

$ make
/Library/Developer/CommandLineTools/usr/bin/make -C lib all
/Library/Developer/CommandLineTools/usr/bin/make -C parson libparson.a
make[2]: `libparson.a' is up to date.
/Library/Developer/CommandLineTools/usr/bin/make -C sha1 libsha1.a
make[2]: `libsha1.a' is up to date.
/Library/Developer/CommandLineTools/usr/bin/make -C src all
cc -Wall -DNDEBUG -O2 -DGIT_COMMIT=\"01002c7\" -I. -I../lib -c -o exhaustive/exhaustive.o exhaustive/exhaustive.c
In file included from exhaustive/exhaustive.c:24:
./util/timeout.h:20:17: error: unknown type name 'timer_t'; did you mean 'time_t'?
extern __thread timer_t *timeout_timer;
                ^~~~~~~
                time_t
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_time_t.h:31:33: note: 'time_t' declared here
typedef __darwin_time_t         time_t;
                                ^
exhaustive/exhaustive.c:305:3: error: use of undeclared identifier 'SIGEV_THREAD_ID'
                timeout_start(cfg->timeout) {
                ^
./util/timeout.h:35:24: note: expanded from macro 'timeout_start'
                sevp->sigev_notify = SIGEV_THREAD_ID;                 \
                                     ^
exhaustive/exhaustive.c:305:3: error: no member named '_sigev_un' in 'struct sigevent'
                timeout_start(cfg->timeout) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./util/timeout.h:38:9: note: expanded from macro 'timeout_start'
                sevp->_sigev_un._tid = (__pid_t)syscall(SYS_gettid);  \
                ~~~~  ^
exhaustive/exhaustive.c:305:3: error: use of undeclared identifier '__pid_t'
./util/timeout.h:38:27: note: expanded from macro 'timeout_start'
                sevp->_sigev_un._tid = (__pid_t)syscall(SYS_gettid);  \
                                        ^
exhaustive/exhaustive.c:305:3: warning: implicit declaration of function 'timer_create' is invalid in C99 [-Wimplicit-function-declaration]
./util/timeout.h:40:3: note: expanded from macro 'timeout_start'
                timer_create(CLOCK_MONOTONIC, sevp, timeout_timer);   \
                ^
exhaustive/exhaustive.c:305:3: error: variable has incomplete type 'struct itimerspec'
./util/timeout.h:41:21: note: expanded from macro 'timeout_start'
                struct itimerspec timer_time = {                      \
                                  ^
exhaustive/exhaustive.c:305:3: note: forward declaration of 'struct itimerspec'
./util/timeout.h:41:10: note: expanded from macro 'timeout_start'
                struct itimerspec timer_time = {                      \
                       ^
exhaustive/exhaustive.c:305:3: warning: implicit declaration of function 'timer_settime' is invalid in C99 [-Wimplicit-function-declaration]
                timeout_start(cfg->timeout) {
                ^
./util/timeout.h:44:3: note: expanded from macro 'timeout_start'
                timer_settime(*timeout_timer, 0, &timer_time, NULL);  \
                ^
exhaustive/exhaustive.c:314:3: warning: implicit declaration of function 'timer_delete' is invalid in C99 [-Wimplicit-function-declaration]
                timeout_stop();
                ^
./util/timeout.h:56:4: note: expanded from macro 'timeout_stop'
                        timer_delete(*timeout_timer); \
                        ^
3 warnings and 5 errors generated.
make[1]: *** [exhaustive/exhaustive.o] Error 1
make: *** [all] Error 2

'make test' does not return an error when it should

Something is going sideways with testing. I have to look into it, but...

My make test recipe looks like so:

MAKE_FLAGS=("test")
if ! "${MAKE}" "${MAKE_FLAGS[@]}"
then
    echo ""
    echo "************************"
    echo "Failed to test ecgen"
    echo "************************"
    exit 1
fi

The makefile does not return an error, so I go onto my make install recipe even though there's clearly problems. Instead of moving on to make install, I should be seeing the Failed to test ecgen message and then an exit from my script.


Here are the problems I am seeing during make test. It looks like some scripts are missing from the release tarball.

************************
Testing package
************************
make -C lib all
make[1]: Entering directory '/home/test/Build-Scripts/ecgen-0.7.3/lib'
make -C parson libparson.a
make[2]: Entering directory '/home/test/Build-Scripts/ecgen-0.7.3/lib/parson'
make[2]: 'libparson.a' is up to date.
make[2]: Leaving directory '/home/test/Build-Scripts/ecgen-0.7.3/lib/parson'
make -C sha1 libsha1.a
make[2]: Entering directory '/home/test/Build-Scripts/ecgen-0.7.3/lib/sha1'
make[2]: 'libsha1.a' is up to date.
make[2]: Leaving directory '/home/test/Build-Scripts/ecgen-0.7.3/lib/sha1'
make[1]: Leaving directory '/home/test/Build-Scripts/ecgen-0.7.3/lib'
make -C src all
make[1]: Entering directory '/home/test/Build-Scripts/ecgen-0.7.3/src'
/usr/bin/cc -I/home/test/ok2delete/include -DNDEBUG -I. -I../lib -DNDEBUG -O2 -DGIT_COMMIT=\"86d9b79\" -Wall -o ecgen ecgen.o io/cli.o io/output.o io/input.o cm/cm.o cm/anomalous.o cm/p1363.o cm/cm_prime.o cm/cm_any.o cm/supersingular.o invalid/invalid_thread.o invalid/invalid.o math/subgroup.o math/twists.o math/poly.o math/koblitz.o gen/metadata.o gen/hex.o gen/curve.o gen/gens.o gen/order.o gen/equation.o gen/field.o gen/seed.o gen/point.o misc/types.o misc/config.o util/str.o util/memory.o util/timeout.o util/random.o util/bits.o exhaustive/check.o exhaustive/brainpool_rfc.o exhaustive/arg.o exhaustive/ansi.o exhaustive/brainpool.o exhaustive/exhaustive.o obj/subgroup.o obj/curve.o obj/point.o -L../lib/parson -L../lib/sha1 -L../lib/pari -L/home/test/ok2delete/lib -Wl,-R,'$ORIGIN/../lib' -Wl,-R,/home/test/ok2delete/lib -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,origin -lrt -lpari -lpthread -lparson -lsha1 -ldl -lpthread
mv ecgen ..
make[1]: Leaving directory '/home/test/Build-Scripts/ecgen-0.7.3/src'
make -C test test
make[1]: Entering directory '/home/test/Build-Scripts/ecgen-0.7.3/test'
./ecgen.sh
./ecgen.sh: line 188: lib/assert.sh/assert.sh: No such file or directory

######################################################################
[*] Test runs                ./ecgen.sh: line 13: assert_raises: command not found
./ecgen.sh: line 14: assert_raises: command not found
./ecgen.sh: line 15: assert_raises: command not found

[*] Test json                ./ecgen.sh: line 20: assert_raises: command not found
./ecgen.sh: line 21: assert_raises: command not found
./ecgen.sh: line 24: assert_raises: command not found
./ecgen.sh: line 25: assert_matches: command not found
./ecgen.sh: line 26: assert_matches: command not found
./ecgen.sh: line 27: assert_matches: command not found
./ecgen.sh: line 28: assert_matches: command not found
./ecgen.sh: line 30: assert_raises: command not found
./ecgen.sh: line 31: assert_matches: command not found
./ecgen.sh: line 32: assert_matches: command not found
./ecgen.sh: line 33: assert_matches: command not found
./ecgen.sh: line 34: assert_matches: command not found
./ecgen.sh: line 35: assert_matches: command not found
./ecgen.sh: line 36: assert_matches: command not found
./ecgen.sh: line 37: assert_matches: command not found

[*] Test exhaustive          ./ecgen.sh: line 42: assert_raises: command not found
./ecgen.sh: line 43: assert_raises: command not found
./ecgen.sh: line 44: assert_raises: command not found
./ecgen.sh: line 45: assert_raises: command not found
./ecgen.sh: line 46: assert_raises: command not found
./ecgen.sh: line 47: assert_raises: command not found
./ecgen.sh: line 48: assert_raises: command not found
./ecgen.sh: line 49: assert_raises: command not found
./ecgen.sh: line 50: assert_raises: command not found
./ecgen.sh: line 51: assert_raises: command not found
./ecgen.sh: line 52: assert_raises: command not found
./ecgen.sh: line 53: assert_raises: command not found
./ecgen.sh: line 55: assert_raises: command not found
./ecgen.sh: line 57: assert_raises: command not found
./ecgen.sh: line 58: assert_raises: command not found
./ecgen.sh: line 59: assert_raises: command not found
./ecgen.sh: line 60: assert_raises: command not found
./ecgen.sh: line 61: assert_raises: command not found
./ecgen.sh: line 62: assert_raises: command not found
./ecgen.sh: line 64: assert_raises: command not found
./ecgen.sh: line 65: assert_raises: command not found
./ecgen.sh: line 66: assert_raises: command not found
./ecgen.sh: line 67: assert_raises: command not found
./ecgen.sh: line 68: assert_raises: command not found
./ecgen.sh: line 69: assert_raises: command not found
./ecgen.sh: line 71: assert_raises: command not found
./ecgen.sh: line 73: assert_raises: command not found
./ecgen.sh: line 75: assert_raises: command not found
./ecgen.sh: line 76: assert_raises: command not found

[*] Test ansix962            ./ecgen.sh: line 81: assert_raises: command not found
./ecgen.sh: line 82: assert_raises: command not found

[*] Test brainpool           ./ecgen.sh: line 87: assert_raises: command not found
./ecgen.sh: line 88: assert_raises: command not found
./ecgen.sh: line 89: assert_raises: command not found
./ecgen.sh: line 90: assert_raises: command not found

[*] Test anomalous           ./ecgen.sh: line 95: assert_raises: command not found
./ecgen.sh: line 97: lib/JSON.sh/JSON.sh: No such file or directory
./ecgen.sh: line 98: lib/JSON.sh/JSON.sh: No such file or directory
./ecgen.sh: line 99: assert: command not found

[*] Test supersingular       ./ecgen.sh: line 104: assert_raises: command not found
./ecgen.sh: line 106: lib/JSON.sh/JSON.sh: No such file or directory
./ecgen.sh: line 107: lib/JSON.sh/JSON.sh: No such file or directory
./ecgen.sh: line 109: assert: command not found
./ecgen.sh: line 111: assert_raises: command not found
./ecgen.sh: line 112: assert_raises: command not found
./ecgen.sh: line 113: assert_raises: command not found
./ecgen.sh: line 114: assert_raises: command not found
./ecgen.sh: line 115: assert_raises: command not found
./ecgen.sh: line 116: assert_raises: command not found

[*] Test invalid             ./ecgen.sh: line 121: assert_raises: command not found
./ecgen.sh: line 122: assert_raises: command not found
./ecgen.sh: line 123: assert_raises: command not found
./ecgen.sh: line 124: assert_raises: command not found
./ecgen.sh: line 125: assert_raises: command not found
./ecgen.sh: line 126: assert_raises: command not found
./ecgen.sh: line 127: assert_raises: command not found
./ecgen.sh: line 128: assert_raises: command not found
./ecgen.sh: line 129: assert_raises: command not found
./ecgen.sh: line 130: assert_raises: command not found

[*] Test twist               ./ecgen.sh: line 135: assert_raises: command not found
./ecgen.sh: line 136: assert_raises: command not found

[*] Test cli                 ./ecgen.sh: line 141: assert_raises: command not found
./ecgen.sh: line 142: assert_raises: command not found
./ecgen.sh: line 143: assert_raises: command not found
./ecgen.sh: line 144: assert_raises: command not found
./ecgen.sh: line 145: assert_raises: command not found
./ecgen.sh: line 146: assert_raises: command not found
./ecgen.sh: line 147: assert_raises: command not found
./ecgen.sh: line 148: assert_raises: command not found
./ecgen.sh: line 149: assert_raises: command not found
./ecgen.sh: line 150: assert_raises: command not found
./ecgen.sh: line 151: assert_raises: command not found
./ecgen.sh: line 152: assert_raises: command not found
./ecgen.sh: line 153: assert_raises: command not found
./ecgen.sh: line 154: assert_raises: command not found

[*] Test hex                 ./ecgen.sh: line 159: assert_raises: command not found

[*] Test cm                  ./ecgen.sh: line 164: assert_raises: command not found
./ecgen.sh: line 165: assert_raises: command not found
./ecgen.sh: line 166: assert_raises: command not found
./ecgen.sh: line 167: assert_raises: command not found
./ecgen.sh: line 168: assert_raises: command not found

[*] Test secg                ./ecgen.sh: line 178: assert_matches: command not found
./ecgen.sh: line 178: assert_matches: command not found
./ecgen.sh: line 178: assert_matches: command not found
./ecgen.sh: line 178: assert_matches: command not found
./ecgen.sh: line 178: assert_matches: command not found
./common.sh: line 21: assert_end: command not found
######################################################################

make[1]: Leaving directory '/home/test/Build-Scripts/ecgen-0.7.3/test'

************************
Installing package
************************
...

Golang elliptic.CurveParams compatibility

Greetings!

Could you tell me how to generate curves compatible with the Go language's elliptic.CurveParams library?

It happens that none of the generated parameters works for digital signature. How to proceed?

Thanks in advance.

Fix Makefiles

I'm building the latest ecgen tarball against PARI/GP 2.13.0. PARI/GP 2.13.0 was released in January 2021. All warez have been installed into $HOME/ok2delete. PARI/GP is not located in /usr and friends.

There were lots of compile errors due to missing functions and implicit declarations. The problem was, the ecgen Makefiles were stomping on my CPPFLAGS, CFLAGS, LDFLAGS and LIBS. The user owns those flags and they should not be touched.

The fix is for ecgen to use its own flags, ECGEN_CFLAGS, ECGEN_LDFLAGS and ECGEN_LIBS, and then use them in the build recipe like:

 ifeq ($(DEBUG), 1)
-    CFLAGS += -DDEBUG -g -Og -Werror -pedantic
+    ECGEN_CFLAGS = -DDEBUG -g -Og -Werror -pedantic
 else ifeq ($(TEST), 1)
-	CFLAGS += -DNDEBUG --coverage -g -O0
+	ECGEN_CFLAGS = -DNDEBUG --coverage -g -O0
 else ifeq ($(FAST), 1)
     ifeq ($(CC), gcc)
-        CFLAGS += -DNDEBUG -O3 -march=native -pipe
+        ECGEN_CFLAGS = -DNDEBUG -O3 -march=native -pipe
     else
-        CFLAGS += -DNDEBUG -O3
+        ECGEN_CFLAGS = -DNDEBUG -O3
     endif
 else
-    CFLAGS += -DNDEBUG -O2
+    ECGEN_CFLAGS = -DNDEBUG -O2
 endif
 
-LDFLAGS = -L../lib/parson -L../lib/sha1 -L../lib/pari
+ECGEN_LDFLAGS = -L../lib/parson -L../lib/sha1 -L../lib/pari
 ifeq ($(STATIC), 1)
-	LIBS = -lrt -Wl,-Bstatic -lpari -Wl,-Bdynamic -lpthread -lparson -lsha1 -lm -lgmp -ldl
+	ECGEN_LIBS = -lrt -Wl,-Bstatic -lpari -Wl,-Bdynamic -lpthread -lparson -lsha1 -lm -lgmp -ldl
 else
-	LIBS = -lrt -lpari -lpthread -lparson -lsha1
+	ECGEN_LIBS = -lrt -lpari -lpthread -lparson -lsha1
 endif
 
-INCLUDES = -I. -I../lib
+ECGEN_INCLUDES = -I. -I../lib
 
 
-GIT_COMMIT = $(shell git rev-parse --short HEAD)
+GIT_COMMIT = $(shell git rev-parse --short HEAD 2>/dev/null)
 ifneq ($(GIT_COMMIT),)
-	CFLAGS += -DGIT_COMMIT=\"$(GIT_COMMIT)\"
+	ECGEN_CFLAGS += -DGIT_COMMIT=\"$(GIT_COMMIT)\"
 endif
...

 all: ecgen
 
 ecgen: ecgen.o $(ECGEN_OBJ)
-	$(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ $(LDFLAGS) $(LIBS)
+	$(CC) $(strip $(CPPFLAGS) $(ECGEN_INCLUDES) $(ECGEN_CFLAGS) $(CFLAGS) -o) $@ $^ $(ECGEN_LDFLAGS) $(LDFLAGS) $(ECGEN_LIBS) $(LIBS)
 	mv ecgen ..
 
 %.o: %.c
-	$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
+	$(CC) $(strip $(CPPFLAGS) $(ECGEN_INCLUDES) $(ECGEN_CFLAGS) $(CFLAGS) -c -o) $@ $<

In the diff... if the user does nothing special, then all of the current ecgen defaults are used. If the user provides flags, like CPPFLAGS="-I /home/test/ok2delete/include" or LDFLAGS="-L /home/test/ok2delete/lib", then they are used during the build.

The call to $(strip ...) cleans up a GCC invocation by remove extraneous whitespace. It makes the output look nice:

/usr/bin/cc -I/home/test/ok2delete/include -DNDEBUG -I. -I../lib -DNDEBUG -O2 -DGIT_COMMIT=\"f8a65c5\" -Wall -c -o ecgen.o ecgen.c
/usr/bin/cc -I/home/test/ok2delete/include -DNDEBUG -I. -I../lib -DNDEBUG -O2 -DGIT_COMMIT=\"f8a65c5\" -Wall -c -o io/cli.o io/cli.c
/usr/bin/cc -I/home/test/ok2delete/include -DNDEBUG -I. -I../lib -DNDEBUG -O2 -DGIT_COMMIT=\"f8a65c5\" -Wall -c -o io/output.o io/output.c
...

The strategy is consistent with GNU's coding standards. The good thing about following GNU's advice here is, it actually avoids the compile problems a user experiences due to whacking a user's flags. Also see Section 7.2.3, Variables for Specifying Commands in the GNU manual.

Here is a patch that fixes the build: ecgen.patch.zip.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.