;
; Installation script for the date.library
;
; created on 09.06.1995 by Kai Hofmann
;

(if (= @language "english") ;then
    (
     (set #welcome (cat "Welcome to the date.library which is "
                    "copyrighted 1994-95 by KaiHofmann\n\n"
                    "This is a portable ANSI-C/C++ library "
                    "that gives you low level functions for "
                    "date calculations.\n\n")
     )
     (set #iuquest ("What do you want to do with the %s?\n\n" @app-name))
     (set #iuc1    "Install")
     (set #iuc2    "Uninstall")
     (set #use33   ("You must be using Kickstart 1.2 or higher to install and use the %s" @app-name))
     (set #libdestdir ("Where do you want to install the %s?" @app-name))
     (set #choiceyes "Yes")
     (set #choiceno "No")
     (set #asksource "Do you want to install the C/C++ source?")
     (set #askcsrc "What do you want to install?")
     (set #askopt1 "Date.h/Date_pragmas.h to include:")
     (set #askopt2 "All source code")
     (set #askopt3 "Documentation")
     (set #notfound "Sorry could not find '%s'")
     (set #copy1 "Copying Date.h to include:libraries")
     (set #copy2 "Copying Date_pragmas.h to include:pragmas")
     (set #askcdoc "Which format do you want to copy?")
     (set #askopt4 "ASCII format")
     (set #askopt5 "AmigaGuide format")
     (set #copy3 "Copying Date.doc")
     (set #copy4 "Copying TextEngine.doc")
     (set #copy5 "Copying Date.guide")
     (set #copy6 "Copying TextEngine.guide")
     (set #copy7 "Copying C-source")
     (set #docdestdir "To which directory should I copy the .doc files?")
     (set #guidedestdir "To which directory should I copy the .guide files?")
     (set #del1 "Deleting .info file - it is created by an installer bug!")
     (set #srcdestdir "Where do you want to install all the sources?")
     (set #removelib ("Removing %s" @app-name))
     (set #libnotfound ("Sorry, could not find %s" @app-name))
     (set #endunin ("\nUninstalling %s finished, but if you have installed the complete source, so please remove this by hand!" @app-name))
    )
)

(if (= 0 (askchoice (prompt #iuquest)
                    (choices #iuc1 #iuc2)
                    (default 0)
                    (help @askchoice-help)
         )
    )
    (
     ; Install
     (if (< (/ (getversion) 65536) 33)
         (abort #use33)
     )
     (welcome #welcome)
     (complete 0)
     (set @default-dest "libs:")
     (set @default-dest (askdir (prompt #libdestdir)
                                (default @default-dest)
                                (help @askdir-help)
                        )
     )
     (if (= @language "english") ;then
         (
          (set #cplprompt ("Copying %s to %s" @app-name @default-dest))
         )
     )

     (set cpu (database "cpu"))
;     (if (patmatch cpu "68000")
         (copylib (prompt #cplpromt)
                  (source "libs/date.library")
                  (dest @default-dest)
                  (newname "date.library")
                  (optional "askuser")
                  (help @copylib-help)
         )
;        (
;         (copylib (prompt #cplpromt)
;                  (source ("libs/date%s.library" (substr cpu 3 2)))
;                  (dest @default-dest)
;                  (newname "date.library")
;                  (optional "askuser")
;                  (help @copylib-help)
;         )
;        )
;     )
     (if (> @user-level 0)
         (
          (complete 50)
          (set src (askoptions (prompt #askcsrc)
                               (choices #askopt1 #askopt2 #askopt3)
                               (default %101)
                               (help @askoptions-help)
                   )
          )
          (if (BITAND src %001)
              (if (= 2 (exists "include:" (noreq)))
                  (
                   (if (= 2 (exists "include:libraries" (noreq)))
                       (copyfiles (prompt #copy1)
                                  (source "src/Date.h")
                                  (dest "include:libraries")
                                  (optional "askuser")
                                  (help @copyfiles-help)
                       )
                       (message (#notfound "include:libraries"))
                   )
                   (if (= 2 (exists "include:pragmas" (noreq)))
                       (copyfiles (prompt #copy2)
                                  (source "src/Date_pragmas.h")
                                  (dest "include:pragmas")
                                  (optional "askuser")
                                  (help @copyfiles-help)
                       )
                       (message (#notfound "include:pragmas"))
                   )
                  )
                  (message (#notfound "include:"))
              )
          )
          (complete 66)
          (set destination "SYS:")
          (if (BITAND src %010)
              (
               (set destination (askdir (prompt #srcdestdir)
                                        (default destination)
                                        (help @askdir-help)
                                )
               )
               (copyfiles (prompt #copy7)
                          (source "src/")
                          (dest destination)
                          (all)
                          (infos)
                          (optional "askuser")
                          (help @copyfiles-help)
               )
               (copyfiles (prompt #copy7)
                          (source "libs/Date.fd")
                          (dest destination)
                          (infos)
                          (optional "askuser")
                          (help @copyfiles-help)
               )
               (delete (tackon destination ".info")
                       (prompt #del1)
                       (optional "force")
                       (help @delete-help)
               )

              )
          )
          (complete 82)
          (if (BITAND src %100)
              (
               (set src (askoptions (prompt #askcdoc)
                                    (choices #askopt4 #askopt5)
                                    (default %10)
                                    (help @askoptions-help)
                        )
               )
               (if (BITAND src %01)
                   (
                    (set destination (askdir (prompt #docdestdir)
                                             (default destination)
                                             (help @askdir-help)
                                     )
                    )
                    (copyfiles (prompt #copy3)
                               (source "doc/Date.doc")
                               (dest destination)
                               (infos)
                               (optional "askuser")
                               (help @copyfiles-help)
                    )
                    (copyfiles (prompt #copy4)
                               (source "doc/TextEngine.doc")
                               (dest destination)
                               (infos)
                               (optional "askuser")
                               (help @copyfiles-help)
                    )
                    (delete (tackon destination ".info")
                            (prompt #del1)
                            (optional "force")
                            (help @delete-help)
                    )
                  )
               )
               (if (BITAND src %10)
                   (
                    (set destination (askdir (prompt #guidedestdir)
                                             (default destination)
                                             (help @askdir-help)
                                     )
                    )
                    (copyfiles (prompt #copy5)
                               (source "doc/Date.guide")
                               (dest destination)
                               (infos)
                               (optional "askuser")
                               (help @copyfiles-help)
                    )
                    (copyfiles (prompt #copy6)
                               (source "doc/TextEngine.guide")
                               (dest destination)
                               (infos)
                               (optional "askuser")
                               (help @copyfiles-help)
                    )
                    (delete (tackon destination ".info")
                            (prompt #del1)
                            (optional "force")
                            (help @delete-help)
                    )
                   )
               )
              )
          )
         )
     )
     (complete 100)
    )
;else
    (
     ; Uninstall
     (if (exists "libs:date.library" (noreq))
         (delete "libs:date.library"
                 (prompt #removelib)
                 (help @delete-help)
                 (optional "force")
         )
         (message #libnotfound)
     )
     (complete 50)
     (if (exists "include:" (noreq))
         (
          (if (exists "include:libraries" (noreq))
              (if (exists "include:libraries/Date.h" (noreq))
                  (delete "include:libraries/Date.h"
                          (prompt #removelib)
                          (help @delete-help)
                          (optional "force")
                  )
              )
          )
          (complete 75)
          (if (exists "include:pragmas" (noreq))
              (if (exists "include:pragmas/Date_pragmas.h" (noreq))
                  (delete "include:pragmas/Date_pragmas.h"
                          (prompt #removelib)
                          (help @delete-help)
                          (optional "force")
                  )
              )
          )
         )
     )
     (complete 100)
     (message #endunin)
     (exit (quiet))
    )
)
