Skip to content

Commit

Permalink
Added Windows support via MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
mickolaua committed Aug 22, 2023
1 parent 137abe7 commit e9ce9b5
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
82 changes: 82 additions & 0 deletions Makefile.Win
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#############################################################
# TO BE CHANGED BY EACH USER TO POINT TO include/ AND lib/
# DIRS HOLDING CFITSIO *.h AND libcfitsio IF THEY ARE NOT IN
# THE STANDARD PLACES
#

CFITSIOINCDIR = E:\\Programs\\msys64\\mingw64\\include
LIBDIR = E:\\Programs\\msys64\\mingw64\\lib
BINDIR = E:\\Programs\\msys64\\mingw64\\bin

#
#
#############################################################
# COMPILATION OPTIONS BELOW
#

# another good memory checker is valgrind : http://valgrind.kde.org/index.html
# valgrind --tool=memcheck hotpants

# for memory checking with libefence
# LIBS = -L$(LIBDIR) -lm -lcfitsio -lefence

# for profiling with gprof
# COPTS = -pg -fprofile-arcs -funroll-loops -O3 -ansi -pedantic-errors -Wall -I$(CFITSIOINCDIR)

# for gdbugging
# COPTS = -g3 -funroll-loops -O3 -ansi -pedantic-errors -Wall -I$(CFITSIOINCDIR)

# standard usage
# recently added -std=c99 after a bug report
COPTS = -funroll-loops -fcommon -O3 -ansi -std=c99 -pedantic-errors -Wall -I$(CFITSIOINCDIR) -D_GNU_SOURCE -DSIZEOF_VOID_P=8 -DMS_WIN64 -static
LIBS = -L$(LIBDIR) -lm -lcfitsio -L$(LBINDIR) -lz

# compiler
CC = gcc

#
#
#############################################################
# BELOW SHOULD BE OK, UNLESS YOU WANT TO COPY THE EXECUTABLES
# SOMEPLACE AFTER THEY ARE BUILT eg. hotpants
#

STDH = functions.h globals.h defaults.h
ALL = main.o vargs.o alard.o functions.o

all: hotpants extractkern maskim

hotpants: $(ALL)
$(CC) $(ALL) -o hotpants $(LIBS) $(COPTS)
# cp hotpants ../../bin/$(ARCH)

main.o: $(STDH) main.c
$(CC) $(COPTS) -c main.c

alard.o: $(STDH) alard.c
$(CC) $(COPTS) -c alard.c

functions.o: $(STDH) functions.c
$(CC) $(COPTS) -c functions.c

vargs.o: $(STDH) vargs.c
$(CC) $(COPTS) -c vargs.c

extractkern : extractkern.o
$(CC) extractkern.o -o extractkern $(LIBS) $(COPTS)

extractkern.o : $(STDH) extractkern.c
$(CC) $(COPTS) -c extractkern.c

maskim : maskim.o
$(CC) maskim.o -o maskim $(LIBS) $(COPTS)

maskim.o: $(STDH) maskim.c
$(CC) $(COPTS) -c maskim.c

clean :
rm -f *.o
rm -f *~ .*~
rm -f hotpants
rm -f extractkern
rm -f maskim
14 changes: 13 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include "globals.h"
#include "functions.h"


#ifdef __MINGW32__
#include <stddef.h>
#endif


int main(int argc,char *argv[]) {
int i,j,k,l,m; /* generic indices */
char scrStr[SCRLEN]; /* scratch string */
Expand Down Expand Up @@ -248,7 +254,13 @@ int main(int argc,char *argv[]) {
fits_write_key_str(oPtr, "AUTHOR", "unknown", "Who ran the software", &status);

/* host name */
if (!gethostname(hInfo, 80))
#ifdef __MINGW32__
strncpy(hInfo, "Unknown", sizeof(hInfo)/sizeof(char));
#else
gethostname(hInfo, 80);
#endif

if (hInfo)
fits_write_key_str(oPtr, "ORIGIN", hInfo, "Where it was done", &status);

/* what was it fired up */
Expand Down

0 comments on commit e9ce9b5

Please sign in to comment.