Skip to content

Commit e9ce9b5

Browse files
committed
Added Windows support via MinGW
1 parent 137abe7 commit e9ce9b5

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

Makefile.Win

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#############################################################
2+
# TO BE CHANGED BY EACH USER TO POINT TO include/ AND lib/
3+
# DIRS HOLDING CFITSIO *.h AND libcfitsio IF THEY ARE NOT IN
4+
# THE STANDARD PLACES
5+
#
6+
7+
CFITSIOINCDIR = E:\\Programs\\msys64\\mingw64\\include
8+
LIBDIR = E:\\Programs\\msys64\\mingw64\\lib
9+
BINDIR = E:\\Programs\\msys64\\mingw64\\bin
10+
11+
#
12+
#
13+
#############################################################
14+
# COMPILATION OPTIONS BELOW
15+
#
16+
17+
# another good memory checker is valgrind : http://valgrind.kde.org/index.html
18+
# valgrind --tool=memcheck hotpants
19+
20+
# for memory checking with libefence
21+
# LIBS = -L$(LIBDIR) -lm -lcfitsio -lefence
22+
23+
# for profiling with gprof
24+
# COPTS = -pg -fprofile-arcs -funroll-loops -O3 -ansi -pedantic-errors -Wall -I$(CFITSIOINCDIR)
25+
26+
# for gdbugging
27+
# COPTS = -g3 -funroll-loops -O3 -ansi -pedantic-errors -Wall -I$(CFITSIOINCDIR)
28+
29+
# standard usage
30+
# recently added -std=c99 after a bug report
31+
COPTS = -funroll-loops -fcommon -O3 -ansi -std=c99 -pedantic-errors -Wall -I$(CFITSIOINCDIR) -D_GNU_SOURCE -DSIZEOF_VOID_P=8 -DMS_WIN64 -static
32+
LIBS = -L$(LIBDIR) -lm -lcfitsio -L$(LBINDIR) -lz
33+
34+
# compiler
35+
CC = gcc
36+
37+
#
38+
#
39+
#############################################################
40+
# BELOW SHOULD BE OK, UNLESS YOU WANT TO COPY THE EXECUTABLES
41+
# SOMEPLACE AFTER THEY ARE BUILT eg. hotpants
42+
#
43+
44+
STDH = functions.h globals.h defaults.h
45+
ALL = main.o vargs.o alard.o functions.o
46+
47+
all: hotpants extractkern maskim
48+
49+
hotpants: $(ALL)
50+
$(CC) $(ALL) -o hotpants $(LIBS) $(COPTS)
51+
# cp hotpants ../../bin/$(ARCH)
52+
53+
main.o: $(STDH) main.c
54+
$(CC) $(COPTS) -c main.c
55+
56+
alard.o: $(STDH) alard.c
57+
$(CC) $(COPTS) -c alard.c
58+
59+
functions.o: $(STDH) functions.c
60+
$(CC) $(COPTS) -c functions.c
61+
62+
vargs.o: $(STDH) vargs.c
63+
$(CC) $(COPTS) -c vargs.c
64+
65+
extractkern : extractkern.o
66+
$(CC) extractkern.o -o extractkern $(LIBS) $(COPTS)
67+
68+
extractkern.o : $(STDH) extractkern.c
69+
$(CC) $(COPTS) -c extractkern.c
70+
71+
maskim : maskim.o
72+
$(CC) maskim.o -o maskim $(LIBS) $(COPTS)
73+
74+
maskim.o: $(STDH) maskim.c
75+
$(CC) $(COPTS) -c maskim.c
76+
77+
clean :
78+
rm -f *.o
79+
rm -f *~ .*~
80+
rm -f hotpants
81+
rm -f extractkern
82+
rm -f maskim

main.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
#include "globals.h"
1313
#include "functions.h"
1414

15+
16+
#ifdef __MINGW32__
17+
#include <stddef.h>
18+
#endif
19+
20+
1521
int main(int argc,char *argv[]) {
1622
int i,j,k,l,m; /* generic indices */
1723
char scrStr[SCRLEN]; /* scratch string */
@@ -248,7 +254,13 @@ int main(int argc,char *argv[]) {
248254
fits_write_key_str(oPtr, "AUTHOR", "unknown", "Who ran the software", &status);
249255

250256
/* host name */
251-
if (!gethostname(hInfo, 80))
257+
#ifdef __MINGW32__
258+
strncpy(hInfo, "Unknown", sizeof(hInfo)/sizeof(char));
259+
#else
260+
gethostname(hInfo, 80);
261+
#endif
262+
263+
if (hInfo)
252264
fits_write_key_str(oPtr, "ORIGIN", hInfo, "Where it was done", &status);
253265

254266
/* what was it fired up */

0 commit comments

Comments
 (0)